import { getExam } from '@/service';
import { Effect, Reducer } from 'umi';

export interface IndexModelState {
  
}
export interface IndexModelType {
  namespace: 'exam';
  state: IndexModelState;
  effects: {
    getExam:Effect;
  };
  reducers: {
    save: Reducer<IndexModelState>;
    // 启用 immer 之后
    // save: ImmerReducer<IndexModelState>;
  };
  // subscriptions: { setup: Subscription };
}
const PeopleModel: IndexModelType = {
  namespace: 'exam',
  state: {

  },
  // 异步操作，理解为vuex中的action, async/await理解为generator函数的语法糖
  effects: {
    *getExam({payload},{call,put}){
        let result = yield call(getExam, payload)
        console.log(result)
        return result
    }
  },
  // 同步操作，理解为vuex中的mutation
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    }
    // 启用 immer 之后
    // save(state, action) {
    //   state.name = action.payload;
    // },
  },
};
export default PeopleModel

